package com.think.teaching.service.impl;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.think.teaching.mapper.ConfigDataMapper;
import com.think.teaching.model.ConfigData;

@Service
public class ConfigDataServiceImpl extends BaseServiceImpl<ConfigDataMapper, ConfigData> {
	@Value("${platform.website}")
	public String WebSiteSettingKey;
	
	
	public ConfigData getConfigData(String key) {
		QueryWrapper<ConfigData> queryWrapper = new QueryWrapper<ConfigData>();
		queryWrapper.eq("`key`",WebSiteSettingKey + key).eq("delflag", 0);
		return this.getOne(queryWrapper);
	}
	
	public boolean saveConfigData(ConfigData configData) {
		configData.setKey(WebSiteSettingKey + configData.getKey());
		QueryWrapper<ConfigData> queryWrapper = new QueryWrapper<ConfigData>();
		queryWrapper.eq("`key`",configData.getKey()).eq("delflag", 0);
		return this.saveOrUpdate(configData, queryWrapper);
	}
}
